package com.zx.BookSeaReader.ui.booklistdetail;

import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zx.BookSeaReader.R;
import com.zx.BookSeaReader.greendao.entity.Book;

import com.zx.BookSeaReader.ui.base.adapter.ViewHolderImpl;


public class ListBooksHolder extends ViewHolderImpl<Book> {

    private ImageView mIvCover;
    private TextView mTvBookName;
    private TextView mTvAuthor;
    private TextView mTvinfo;
    private TextView mTvType;

    @Override
    public void initView() {
        mIvCover=findById(R.id.book_iv_cover);
        mTvBookName = findById(R.id.book_tv_name);
        mTvAuthor = findById(R.id.book_tv_author);
        mTvinfo = findById(R.id.book_tv_info);
        mTvType = findById(R.id.book_tv_type);
    }

    @Override
    public void onBind(Book data, int pos) {
        Glide.with(getContext())
                .load(data.getImgUrl())
                .placeholder(R.mipmap.no_image)
                .error(R.mipmap.no_image)
                .into(mIvCover);
        mTvBookName.setText(data.getName());
        mTvAuthor.setText(data.getAuthor());
        mTvinfo.setText(data.getDesc());
        mTvType.setText(" | "+data.getType());

    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_book;
    }
}
